home *** CD-ROM | disk | FTP | other *** search
- <?php
- ////////////////////////////////////////////////////////////////////////////////
- // <!--Copyright (c) 2005 Pure Networks Inc. All rights reserved.-->
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Build: 3.0.6121.0 (Stable)
- // $Revision: #2 $
- //
-
- $sNavLocation = "slideshow";
- require "_session_common.php";
- ///////////////////////////////////////////////////
- // Make sure that we have a valid share passed in.
- ///////////////////////////////////////////////////
- if (!isset($_GET['share']) or $_GET['share'] == "")
- {
- log_activity("QS check", "failure", return_error_text(200, "", $arErrors));
- gotoAbs('/error/200/return');
- exit();
- }
- else
- {
- $sShare = $_GET['share'];
- log_activity("slideshow share", "info", $sShare);
- }
- ///////////////////////////////////////////////////
- // Make sure that we have a valid path passed in.
- ///////////////////////////////////////////////////
- if (!isset($_GET['path']) or $_GET['path'] == "")
- {
- log_activity("QS check", "failure", return_error_text(201, "", $arErrors));
- gotoAbs('/error/201/return');
- exit();
- }
- else
- {
- $sPath = urlDecodeString($_GET['path']);
- log_activity("slideshow path", "info", $sPath);
- }
- require '_folderutils.php';
- ///////////////////////////////////////////////////
- // Are we starting a new slideshow or contiuing one?
- ///////////////////////////////////////////////////
- $bStart = false;
- if ($_GET['start'] == "true")
- {
- $bStart = true;
- log_activity("slideshow started", "info", "");
- }
- ///////////////////////////////////////////////////
- // Get information on the share
- ///////////////////////////////////////////////////
- try //TODO what is not needed here?
- {
- $nmSharedPlace = $nmNetworkLib->OpenShare($sShare);
- $sNetworkName = $nmNetworkLib->NetworkName;
- $sContainer = $nmSharedPlace->DisplayName;
- $sUnc = $nmSharedPlace->Unc;
- $sFolderPath = $sPath;
- $sFolderShortPath = basename($sFolderPath);
- }
- catch(Exception $ex)
- {
- log_activity("slideshow", "exception", $ex->getMessage());
- gotoAbs('/error/103');
- exit();
- }
- ///////////////////////////////////////////////////
- // This check only works for a real folder path, not the root UNC path
- ///////////////////////////////////////////////////
- if ((strcmp($sFolderPath, $sUnc) != 0) && !file_exists($sFolderPath))
- {
- // The path does not match up to the share path
- log_activity("slideshow", "error", return_error_text(301, "", $arErrors));
- gotoAbs('/error/301');
- exit();
- }
- ///////////////////////////////////////////////////
- // The user is not logged in, if this is a private share, send them away.
- ///////////////////////////////////////////////////
- if (!$bLoggedIn)
- {
- try
- {
- $sAccessLevel = $nmSharedPlace->AccessLevel;
- }
- catch(Exception $ex)
- {
- log_activity("Attempting nmSharedPlace->AccessLevel", "exception", $ex->getMessage());
- gotoAbs('/error/305/return');
- exit();
- }
-
- if ($sAccessLevel != 0)
- {
- log_activity("private folder request without session", "error", return_error_text(308, "", $arErrors));
- gotoAbs('/login/308');
- exit();
- }
- }
- ///////////////////////////////////////////////////
- // Do we have a file array in session, or should we make one?
- ///////////////////////////////////////////////////
- $cFiles = 0;
- if ($bStart)
- {
- if (isset($_SESSION['SlideshowFileArray']))
- {
- // we're on start, let's wipe any previous slideshow from session and create a new array
- $_SESSION['SlideshowFileArray'] = "";
- $_SESSION['SlideshowHelperArray'] = "";
- }
- createFileArray($sShare, $sFolderPath, $nmSharedPlace);
- }
- else
- {
- if (!isset($_SESSION['SlideshowFileArray']))
- {
- // we're not on start and we don't have a session filearray, we must have been bookmarked
- // let's re-create teh filearray and set the picture to zero
- createFileArray($sShare, $sFolderPath, $nmSharedPlace);
- $iImageNumber = 0;
- }
- else
- {
- // we're not on start and have an array in session, let's compare it to the passed path and
- // make sure it's the correct one to use, if not, blow it away and create one.
- $filesArrayHelper = $_SESSION['SlideshowHelperArray'];
- if ($sShare != $filesArrayHelper[0] OR $sFolderPath != $filesArrayHelper[1])
- {
- $_SESSION['SlideshowFileArray'] = "";
- $_SESSION['SlideshowHelperArray'] = "";
- createFileArray($sShare, $sFolderPath, $nmSharedPlace);
- }
- }
- }
- $filesArray = $_SESSION['SlideshowFileArray'];
- $iFileArraySize = count($filesArray);
-
- ///////////////////////////////////////////////////
- // What is our image number? Let's validate it.
- ///////////////////////////////////////////////////
- $iImageNumber = intval($_GET['image']);
- if ($iImageNumber >= $iFileArraySize)
- {
- // if we hit the end of the array, let's start over at the beginning
- $iImageNumber = 0;
- }
- if ($iImageNumber < 0)
- {
- // if we're on the first picture and someone hit previous, let's go to the end
- $iImageNumber = ($iFileArraySize - 1);
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html>
- <head>
- <?php
- require "_cookie_util.php";
- ?>
- <script type="text/javascript" language="JavaScript">
- writeCookie();
- </script>
- <?php
- $screen_res = $_COOKIE['users_res'];
- $screen_res_tmp = explode("x", $screen_res);
- $screen_width = $screen_res_tmp[0];
- $screen_height = $screen_res_tmp[1];
-
- if ($iFileArraySize > 0)
- {
- ?>
- <meta http-equiv="refresh" content="<?php echo($iRefreshInterval);?>;url=/slideshow/<?php echo($sShare);?>/<?php echo(urlEncodeString($sFolderPath));?>/?image=<?php echo($iImageNumber+1);?>&start=false&refresh=<?php echo($iRefreshSeconds);?>">
- <?php
- }
- ?>
- <title><?php echo htmlspecialchars(returnPageTitle($sIntroHeadline, $sProductNameInformal, $nmSharedPlace, $sPath, $fileName)); ?></title>
- <?php require "_styles_import.php"; ?>
- <script type="text/javascript">
- function show_controls_max()
- {
- document.getElementById('SlideshowMaxContain').style.visibility = 'visible';
- document.getElementById('SlideshowMaxContain').style.display = 'inline';
-
- document.getElementById('SlideshowMinContain').style.visibility = 'hidden';
- document.getElementById('SlideshowMinContain').style.display = 'none';
- }
-
- function show_controls_min()
- {
- document.getElementById('SlideshowMaxContain').style.visibility = 'hidden';
- document.getElementById('SlideshowMaxContain').style.display = 'none';
-
- document.getElementById('SlideshowMinContain').style.visibility = 'visible';
- document.getElementById('SlideshowMinContain').style.display = 'inline';
- }
- </script>
- </head>
- <body class="Slideshow" onLoad="writeCookie();">
- <!--Copyright (c) 2005 Pure Networks Inc. All rights reserved.-->
- <?php
- if ($iFileArraySize > 0)
- {
- $sFullFilePath = $sFolderPath . "\\" . $filesArray[$iImageNumber];
-
- ///////////////////////////////////////////////////
- // get the path to the midsize image
- ///////////////////////////////////////////////////
- try
- {
- $imgLocation = $nmRaManager->GetThumbnailForFile($sFullFilePath, $iSlideshowWidth,
- $iSlideshowHeight, $sContentBackground);
- // let's get the thumbnail's size whiel we have the UNC path to the thumbnail
- $arImageInfo = getimagesize($imgLocation);
- $image_width = $arImageInfo[0];
- $image_height = $arImageInfo[1];
- $iImageType = $arImageInfo[2];
- // GetThumbnailForFile returns an absolute path; turn it into a relative path for
- // HTML consumption.
- $imgLocation = substr($imgLocation, strlen($nmRaManager->AppDataDir));
- $imgLocation = urlEncodeString(str_replace("\\", "/", $imgLocation));
- }
- catch(com_exception $ex)
- {
- // An error occurred while attempting to get the image, display bad image pic
- $imgLocation = "styles/default/image.broken.gif";
- $imgMode = "Bad";
- log_activity("get thumbnail for " . $sFullFilePath, "exception", $ex->getMessage());
- }
- ///////////////////////////////////////////////////
- // do we need to resize the image? Let's start w/ that
- ///////////////////////////////////////////////////
- if (isset($arImageInfo))
- {
- $arImageInfo = array();
- }
- $viewlink = $imgLocation;
- ?>
- <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
- <tr>
- <td>
- <div class="SlideshowImage"><img src="<?php echo ($viewlink); ?>" width="<?php echo($image_width);?>" height="<?php echo($image_height);?>" alt="<?php echo(substr(strrchr($sFullFilePath,"\\"),1)); ?>" /></div>
- </td>
- </tr>
- <tr>
- <td>
- <div id="SlideshowMaxContain" name="SlideshowMaxContain" class="SlideshowMaxContain">
- <table cellpadding="0" cellspacing="0" border="0" width="100%">
- <tr>
- <td class="SlideshowLeft"><div> </div></td>
- <td align="right" class="SlideshowMid">
- <div class="SlideshowButtonContain">
- <span class="SlideshowPrev" onmouseover="this.className='SlideshowPrevHover'" onmouseout="this.className='SlideshowPrev'"><a href="/slideshow/<?php echo($sShare);?>/<?php echo(urlEncodeString($sFolderPath));?>/?image=<?php echo($iImageNumber-1);?>&start=false&refresh=<?php echo($iRefreshSeconds);?>" title="Previous slideshow image"><img src="/images/pixel.trans.gif" alt="" border="0"></a></span>
- <span class="SlideshowNext" onmouseover="this.className='SlideshowNextHover'" onmouseout="this.className='SlideshowNext'"><a href="/slideshow/<?php echo($sShare);?>/<?php echo(urlEncodeString($sFolderPath));?>/?image=<?php echo($iImageNumber+1);?>&start=false&refresh=<?php echo($iRefreshSeconds);?>" title="Next slideshow image"><img src="/images/pixel.trans.gif" alt="" border="0"></a></span>
- </div>
- </td>
- <td align="right" class="SlideshowRight"><div> </div></td>
- </tr>
- </table>
- </div>
-
- <div id="SlideshowMinContain" name="SlideshowMinContain" style="visibility:hidden;display:none;">
- <table cellpadding="0" cellspacing="0" border="0" width="100%" >
- <tr>
- <td width="45%"><div class="SlideshowMinBg"><img src="/images/pixel.trans.gif" width="1" height="1" alt=""></div></td>
- <td class="SlideshowGrabber"><a href="javascript:show_controls_max();"><img src="/images/pixel.trans.gif" border="0"alt=""></a></td>
- <td width="45%"><div class="SlideshowMinBg"><img src="/images/pixel.trans.gif" width="1" height="1" alt=""></div></td>
- </tr>
- </table>
- </div>
-
- </td>
- </tr>
- </table>
- <?php
- ///////////////////////////////////////////////////
- // get the path to the NEXT midsize image to spare cycles
- ///////////////////////////////////////////////////
- $sFullFilePath = $sFolderPath . "\\" . $filesArray[$iImageNumber + 1];
- try
- {
- $imgLocation = $nmRaManager->GetThumbnailForFile($sFullFilePath, $iMidSizeWidth, $iMidSizeHeight, $sContentBackground);
- }
- catch(com_exception $ex)
- {
- log_activity("get thumbnail for " . $sFullFilePath, "exception", $ex->getMessage());
- }
- }
- else
- {
- log_activity("slideshow", "error", return_error_text(xxx, "", $arErrors));
- gotoAbs('/error/401');
- exit();
- }
- ?>
- </body>
- </html>
- <?php
- ///////////////////////////////////////////////////
- // Build up an array of displayable files for session
- ///////////////////////////////////////////////////
- function createFileArray($sShare, $sFolderPath, $nmSharedPlace)
- {
- log_activity("slideshow create", "info", "new session cache");
- $handle = opendir($sFolderPath);
- $filesArray = array();
- while (false !== ($file = readdir($handle)))
- {
- $sFullFilePath = $sFolderPath . "\\" . $file;
- if (!is_dir($sFullFilePath) && ($file != ".") && ($file != ".."))
- {
- $fileExtension = strtolower(strrchr($sFullFilePath, "."));
-
- switch ($fileExtension)
- {
- case ".gif":
- case ".jpg":
- case ".jpe":
- case ".jpeg":
- case ".bmp":
- case ".png":
- // add gif, jpg, bmp, and png files to the slideshow array
- if ($nmSharedPlace->IsDisplayableItem($sFullFilePath) && is_file($sFullFilePath) && is_readable($sFullFilePath))
- {
- $filesArray[] = $file;
- }
- break;
- }
- }
- }
- // Now that we have the files aray, let's create a helper array with info on
- // the share and path for the array in teh session
- $filesArrayHelper = "";
- $filesArrayHelper[0] = $sShare;
- $filesArrayHelper[1] = $sFolderPath;
- // now let's store the arrays in the session
- $_SESSION['SlideshowHelperArray'] = $filesArrayHelper;
- $_SESSION['SlideshowFileArray'] = $filesArray;
- }
- ?>